package com.chuanyekeji.aokai.Controller;

import com.chuanyekeji.aokai.Entity.CompanyBaseInfo;
import com.chuanyekeji.aokai.Mapper.CompanyBaseInfoMapper;
import com.chuanyekeji.aokai.Util.ReturnData;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin(origins = "*",maxAge = 3600)
@RestController
public class CompanyController {

    @Autowired
    CompanyBaseInfoMapper companyBaseInfoMapper;

    /**
     * 获取公司信息
     * @return
     */
    @RequestMapping("getCompanyInfo")
    String getCompanyInfo() {
        CompanyBaseInfo companyBaseInfo = companyBaseInfoMapper.selectByPrimaryKey();
        Gson gson = new Gson();
        return ReturnData.success("success",gson.toJson(companyBaseInfo));
    }

    /**
     * 修改公司信息
     * @param companyBaseInfo
     * @return
     */
    @RequestMapping("changeCompanyInfo")
    String changeCompanyInfo(CompanyBaseInfo companyBaseInfo) {
        CompanyBaseInfo c = companyBaseInfoMapper.selectByPrimaryKey();
        companyBaseInfo.setId(c.getId());
        companyBaseInfoMapper.updateByPrimaryKeySelective(companyBaseInfo);
        return "修改成功";
    }

}
